package com.jetpack_sunflower.data

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey
import java.util.*

/**
 * val name: String,
val description: String,
val growZoneNumber: Int,
val wateringInterval: Int = 7, // how often the plant should be watered, in days
val imageUrl: String = ""
 */

@Entity(tableName = "plant")
data class Plant(
        @PrimaryKey
        @ColumnInfo(name = "id")
        val plantId: String,
        val name: String,
        val description: String,
        val growZoneNumber: Int,
        val wateringInterval: Int = 7,
        val imageUrl: String = ""
) {
    fun shouldBeWatered(since: Calendar, lastWaterTime: Calendar) = {
        since > lastWaterTime.apply {
            add(Calendar.DAY_OF_YEAR, wateringInterval)
        }
    }

    override fun toString() = name
}